<template>
  <div>
    <h1>{{ str }}</h1>
    <button @click="fn">for循环反转</button>
    <button @click="fn1">反转</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      str: '心都碎成二维码了 可扫出来还是我好想你呜呜呜',
    }
  },
  methods: {
    fn() {
      let newStr = ''
      for (let i = this.str.length - 1; i >= 0; i--) {
        newStr = newStr + this.str[i]
      }
      this.str = newStr
    },
    fn1() {
      this.str = this.str.split('').reverse().join('')
    },
  },
}
</script>

<style></style>
